﻿using CGT.OP.App_Start;
using CGT.OP.Common;
using OF.Component;
using OF.Component.BLL;
using OF.Component.DTO;
using OF.Component.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CGT.OP.Controllers
{
    public class MessageController : BaseController
    {
        [Authentication(MenuCode = "cgt2104")]
        // GET: Message
        public ActionResult List()
        {
            return View();
        }

        public PartialViewResult PartialListDataView(MessageCondition pageObj)
        {
            pageObj.rows = GetPageSize();
            pageObj.page = GetPageIndex();
            IList<MessageInfo> list = MessageOperate.SearchList(pageObj);
            ViewBag.OutCount = pageObj.total;
            return PartialView(list);
        }
        [Authentication(MenuCode = "cgt2104")]
        public ActionResult Add()
        {
            return View();
        }
        /// <summary>
        /// 保存消息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ContentResult Save(MessageInfo entity)
        {

            ResultData<long> rData = new ResultData<long>();
            entity.CreatedDate = DateTime.Now;
            entity.OperationID = CurrentUser().UserId.ToString();
            try
            {
                rData.data = MessageOperate.Insert(entity);

            }
            catch (Exception ex)
            {
                rData.status = -1;
            }
            return ReturnResult(rData);
        }
    }
}